package com.wch.util;

//import com.sun.org.apache.xml.internal.security.utils.Base64;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
import java.util.UUID;

public class NoteUtil {

    public static String createId(){
        return UUID.randomUUID().toString();
    }

    public static String md5(String str){
        try {
            MessageDigest md5 =
                MessageDigest.getInstance("MD5");
            byte[] input = str.getBytes();
            byte[] output =  md5.digest(input);
//            System.out.println(output.length);
            //利用Base64算法将byte[]处理成字符串返回
            return Base64.getEncoder().encodeToString(output);

        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
            return "";
        }
    }



    public static void main(String[] args){
        System.out.println(md5("123"));
    }
}
